package com.lmiot.xyclick.Bind;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v7.widget.SwitchCompat;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.lmiot.floatviewsdklibrary.SDK.YYFloatButton;
import com.lmiot.xyclick.Activity.BaseActivity;
import com.lmiot.xyclick.App.MyApp;
import com.lmiot.xyclick.Bean.ChangeDataBean;
import com.lmiot.xyclick.Bean.FinishFloatActivityBean;
import com.lmiot.xyclick.Notic.NoticEnum;
import com.lmiot.xyclick.Notic.NoticManager;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.ClickUtils;
import com.lmiot.xyclick.Util.LayoutDialogUtil;
import com.xiaoyi.intentsdklibrary.SDK.Action.Accessibility;
import com.xiaoyi.intentsdklibrary.SDK.Action.ActionAsSDK;
import com.yhao.floatwindow.FloatUtil;
import com.youyi.yyviewsdklibrary.View.TitleBarView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class FloatSettingActivity extends BaseActivity implements View.OnClickListener {
    private Dialog mDialog;
    private int mFloatColorNum = 1;
    RelativeLayout mIdAsLayout;
    SwitchCompat mIdAsSwitch;
    RelativeLayout mIdFloatColorLayout;
    ImageView mIdFloatmenuImg;
    SeekBar mIdFloatmenuSeekbar;
    SeekBar mIdFloatmenuSeekbarAlph;
    RelativeLayout mIdJumpLayout;
    SwitchCompat mIdJumpSwitch;
    SwitchCompat mIdNotic;
    RelativeLayout mIdNoticLayout;
    RelativeLayout mIdOldLayout;
    SwitchCompat mIdOldSwitch;
    TitleBarView mIdTitleBar;

    /* access modifiers changed from: protected */
    @Override // android.support.v4.app.SupportActivity, com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_float_setting);
        initView();
        init();
        setSeekBar();
        EventBus.getDefault().register(this);
    }

    private void setSeekBar() {
        this.mIdFloatmenuSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            /* class com.lmiot.xyclick.Bind.FloatSettingActivity.AnonymousClass1 */

            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            public void onStopTrackingTouch(SeekBar seekBar) {
            }

            public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
                YYFloatButton.updateSize(MyApp.getContext(), i);
            }
        });
        this.mIdFloatmenuSeekbarAlph.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            /* class com.lmiot.xyclick.Bind.FloatSettingActivity.AnonymousClass2 */

            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            public void onStopTrackingTouch(SeekBar seekBar) {
            }

            public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
                YYFloatButton.updateAlaph(MyApp.getContext(), i);
            }
        });
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(FinishFloatActivityBean finishFloatActivityBean) {
        finish();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(ChangeDataBean changeDataBean) {
        showSetData();
    }

    private void init() {
        this.mIdTitleBar.setOnItemClickListener(new TitleBarView.onItemClickListener() {
            /* class com.lmiot.xyclick.Bind.FloatSettingActivity.AnonymousClass3 */

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onMenuClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onTitleClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onBackClick(View view) {
                FloatSettingActivity.this.finish();
            }
        });
    }

    @Override // com.lmiot.xyclick.Activity.BaseActivity, android.support.v4.app.FragmentActivity
    public void onResume() {
        super.onResume();
        showSetData();
    }

    private void showSetData() {
        showColor();
        this.mIdAsSwitch.setChecked(ActionAsSDK.getShowAsButton(MyApp.getContext()));
        this.mIdNotic.setChecked(NoticManager.getNoticValue(MyApp.getContext(), NoticEnum.FloatNotic));
        this.mIdOldSwitch.setChecked(YYFloatButton.getFloatMode(this));
        this.mIdJumpSwitch.setChecked(FloatUtil.getFloatJump(this));
        this.mIdFloatmenuSeekbar.setProgress(YYFloatButton.getFloatViewSize(MyApp.getContext()));
        this.mIdFloatmenuSeekbarAlph.setProgress(YYFloatButton.getFloatViewAlaph(MyApp.getContext()));
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void showColor() {
        switch (YYFloatButton.getFloatViewColor(MyApp.getContext())) {
            case 1:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.fcolor1));
                return;
            case 2:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.fcolor2));
                return;
            case 3:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.fcolor3));
                return;
            case 4:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.fcolor4));
                return;
            case 5:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.fcolor5));
                return;
            case 6:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.fcolor6));
                return;
            case 7:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.fcolor7));
                return;
            case 8:
                this.mIdFloatmenuImg.setColorFilter(getResources().getColor(R.color.translate));
                return;
            default:
                return;
        }
    }

    private void chosColorDialog() {
        this.mFloatColorNum = YYFloatButton.getFloatViewColor(MyApp.getContext());
        Dialog createDailog = LayoutDialogUtil.createDailog(this, R.layout.dialog_change_color);
        this.mDialog = createDailog;
        createDailog.setCancelable(true);
        RadioGroup radioGroup = (RadioGroup) this.mDialog.findViewById(R.id.id_group1);
        RadioButton radioButton = (RadioButton) this.mDialog.findViewById(R.id.id_bt1);
        RadioButton radioButton2 = (RadioButton) this.mDialog.findViewById(R.id.id_bt2);
        RadioButton radioButton3 = (RadioButton) this.mDialog.findViewById(R.id.id_bt3);
        RadioButton radioButton4 = (RadioButton) this.mDialog.findViewById(R.id.id_bt4);
        RadioGroup radioGroup2 = (RadioGroup) this.mDialog.findViewById(R.id.id_group2);
        RadioButton radioButton5 = (RadioButton) this.mDialog.findViewById(R.id.id_bt5);
        RadioButton radioButton6 = (RadioButton) this.mDialog.findViewById(R.id.id_bt6);
        RadioButton radioButton7 = (RadioButton) this.mDialog.findViewById(R.id.id_bt7);
        RadioButton radioButton8 = (RadioButton) this.mDialog.findViewById(R.id.id_bt8);
        switch (this.mFloatColorNum) {
            case 1:
                radioButton.setChecked(true);
                break;
            case 2:
                radioButton2.setChecked(true);
                break;
            case 3:
                radioButton3.setChecked(true);
                break;
            case 4:
                radioButton4.setChecked(true);
                break;
            case 5:
                radioButton5.setChecked(true);
                break;
            case 6:
                radioButton6.setChecked(true);
                break;
            case 7:
                radioButton7.setChecked(true);
                break;
            case 8:
                radioButton8.setChecked(true);
                break;
        }
        setCheck(radioButton, radioGroup2, 1);
        setCheck(radioButton2, radioGroup2, 2);
        setCheck(radioButton3, radioGroup2, 3);
        setCheck(radioButton4, radioGroup2, 4);
        setCheck(radioButton5, radioGroup, 5);
        setCheck(radioButton6, radioGroup, 6);
        setCheck(radioButton7, radioGroup, 7);
        setCheck(radioButton8, radioGroup, 8);
        ((TextView) this.mDialog.findViewById(R.id.tv_cancel)).setOnClickListener(new View.OnClickListener() {
            /* class com.lmiot.xyclick.Bind.FloatSettingActivity.AnonymousClass4 */

            public void onClick(View view) {
                FloatSettingActivity.this.mDialog.dismiss();
            }
        });
        ((TextView) this.mDialog.findViewById(R.id.tv_sure)).setOnClickListener(new View.OnClickListener() {
            /* class com.lmiot.xyclick.Bind.FloatSettingActivity.AnonymousClass5 */

            public void onClick(View view) {
                FloatSettingActivity.this.mDialog.dismiss();
                YYFloatButton.changeColor(MyApp.getContext(), FloatSettingActivity.this.mFloatColorNum);
                FloatSettingActivity.this.showColor();
            }
        });
    }

    /* access modifiers changed from: package-private */
    public void setCheck(RadioButton radioButton, final RadioGroup radioGroup, final int i) {
        radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            /* class com.lmiot.xyclick.Bind.FloatSettingActivity.AnonymousClass6 */

            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                if (z) {
                    ClickUtils.onlyVibrate(FloatSettingActivity.this);
                    FloatSettingActivity.this.mFloatColorNum = i;
                    radioGroup.clearCheck();
                }
            }
        });
    }

    /* access modifiers changed from: protected */
    @Override // com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    private void initView() {
        this.mIdTitleBar = (TitleBarView) findViewById(R.id.id_title_bar);
        this.mIdJumpSwitch = (SwitchCompat) findViewById(R.id.id_jump_switch);
        this.mIdJumpLayout = (RelativeLayout) findViewById(R.id.id_jump_layout);
        this.mIdAsSwitch = (SwitchCompat) findViewById(R.id.id_as_switch);
        this.mIdAsLayout = (RelativeLayout) findViewById(R.id.id_as_layout);
        this.mIdOldSwitch = (SwitchCompat) findViewById(R.id.id_old_switch);
        this.mIdOldLayout = (RelativeLayout) findViewById(R.id.id_old_layout);
        this.mIdNotic = (SwitchCompat) findViewById(R.id.id_notic);
        this.mIdNoticLayout = (RelativeLayout) findViewById(R.id.id_notic_layout);
        this.mIdFloatColorLayout = (RelativeLayout) findViewById(R.id.id_float_color_layout);
        this.mIdFloatmenuImg = (ImageView) findViewById(R.id.id_floatmenu_img);
        this.mIdFloatmenuSeekbar = (SeekBar) findViewById(R.id.id_floatmenu_seekbar);
        this.mIdFloatmenuSeekbarAlph = (SeekBar) findViewById(R.id.id_floatmenu_seekbar_alph);
        this.mIdJumpSwitch.setOnClickListener(this);
        this.mIdJumpLayout.setOnClickListener(this);
        this.mIdAsSwitch.setOnClickListener(this);
        this.mIdAsLayout.setOnClickListener(this);
        this.mIdOldSwitch.setOnClickListener(this);
        this.mIdOldLayout.setOnClickListener(this);
        this.mIdNotic.setOnClickListener(this);
        this.mIdNoticLayout.setOnClickListener(this);
        this.mIdFloatColorLayout.setOnClickListener(this);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.id_as_layout /*{ENCODED_INT: 2131296468}*/:
                if (this.mIdAsSwitch.isChecked()) {
                    this.mIdAsSwitch.setChecked(false);
                    ActionAsSDK.setShowAsButton(MyApp.getContext(), false);
                } else {
                    this.mIdAsSwitch.setChecked(true);
                    ActionAsSDK.setShowAsButton(MyApp.getContext(), true);
                }
                Accessibility.getInstance().asButtonMethod();
                return;
            case R.id.id_as_switch /*{ENCODED_INT: 2131296470}*/:
                ActionAsSDK.setShowAsButton(MyApp.getContext(), this.mIdAsSwitch.isChecked());
                return;
            case R.id.id_float_color_layout /*{ENCODED_INT: 2131296649}*/:
                chosColorDialog();
                return;
            case R.id.id_jump_layout /*{ENCODED_INT: 2131296731}*/:
                if (this.mIdJumpSwitch.isChecked()) {
                    FloatUtil.setFloatJump(this, false);
                    this.mIdJumpSwitch.setChecked(false);
                    return;
                }
                FloatUtil.setFloatJump(this, true);
                this.mIdJumpSwitch.setChecked(true);
                return;
            case R.id.id_jump_switch /*{ENCODED_INT: 2131296732}*/:
                if (this.mIdJumpSwitch.isChecked()) {
                    FloatUtil.setFloatJump(this, true);
                    return;
                } else {
                    FloatUtil.setFloatJump(this, false);
                    return;
                }
            case R.id.id_notic /*{ENCODED_INT: 2131296799}*/:
                if (this.mIdNotic.isChecked()) {
                    NoticManager.getInstance().show(NoticEnum.FloatNotic);
                    return;
                } else {
                    NoticManager.getInstance().hide(NoticEnum.FloatNotic);
                    return;
                }
            case R.id.id_notic_layout /*{ENCODED_INT: 2131296802}*/:
                if (this.mIdNotic.isChecked()) {
                    this.mIdNotic.setChecked(false);
                    NoticManager.getInstance().hide(NoticEnum.FloatNotic);
                    return;
                }
                this.mIdNotic.setChecked(true);
                NoticManager.getInstance().show(NoticEnum.FloatNotic);
                return;
            case R.id.id_old_layout /*{ENCODED_INT: 2131296814}*/:
                if (this.mIdOldSwitch.isChecked()) {
                    this.mIdOldSwitch.setChecked(false);
                    YYFloatButton.setFloatMode(this, false);
                    return;
                }
                this.mIdOldSwitch.setChecked(true);
                YYFloatButton.setFloatMode(this, true);
                return;
            case R.id.id_old_switch /*{ENCODED_INT: 2131296815}*/:
                if (this.mIdOldSwitch.isChecked()) {
                    YYFloatButton.setFloatMode(this, true);
                    return;
                } else {
                    YYFloatButton.setFloatMode(this, false);
                    return;
                }
            default:
                return;
        }
    }
}
